using UnityEngine;
using QFramework;

namespace QFramework.Monk
{
	public partial class EnemyGreen : EnemyNormal
	{
		private float mRadius = 2;
		private float mAngle;
		protected override void Move()
		{
			if (!AppStart.CheckGameState(GameState.GamePlaying))
			{
				return;
			}
			// 更新角度
			mAngle +=  Time.deltaTime*180;

			// 计算新的位置
			var rad = mAngle.Deg2Rad();
			var newPos = new Vector3(-Mathf.Cos(rad), Mathf.Sin(rad)) * mRadius;
			
			// 空指针检查
			if (Player.Default != null)
			{
				// 方向 旋转运动
				var dir = (Player.Default.transform.position - this.transform.position+newPos).normalized ;
				selfRigidbody2D.velocity = dir*mSpeed;
			}
			else
			{
				selfRigidbody2D.velocity = Vector2.zero;
			}
		}
	}
}
